package arduino;

import java.util.Vector;
 
public class ProcessMessageQueue implements Runnable{
	private MessageQueue messageQueue ;
	//private double signalRange ;
	//private double signalChangeThreshold ;
	//private EventQueue eventQueue;
	//private  MyEvent event;
	ProcessMessageQueue(){
		messageQueue = null;
		//signalRange = 1000.0 ;
		//signalChangeThreshold  = 0.25 ;		
	}

	//ProcessMessageQueue(MessageQueue msq, EventQueue evntQ){
	ProcessMessageQueue(MessageQueue msq){
		messageQueue = msq;
		//eventQueue = evntQ;
		//signalRange = 1000.0 ;
		//signalChangeThreshold  = 0.25 ;				
		//event = new Vector<Integer>();
	}
	
	public void SetMessageQueue(MessageQueue msq){
		messageQueue = msq ;
	}
	
	// look at the pattern in the messages and 
	// try to decide about an event 
	public void run(){
		Vector<MyMessage> myQueue ;
		
		while(true){
			// empty the event vector since we are going to put a new event there
			// event.clear() ;
			// get all existing messages
			// this thread i.e. consumer thread will go to sleep if there are 
			// no existing messages
			myQueue = messageQueue.GetAllMessages();
			//int currentSampleEvent ;
			for(MyMessage msg:myQueue){
				System.out.println("Message source: "+msg.sourceID+" message:"+msg.message);
			} // for(MyPressureMessage msg:myQueue){
			
		} //while(true)
		
	} //public void processMessagesInQueue(){
}
